class DressesController < ApplicationController
  # GET /dresses
  # GET /dresses.xml
  def index
    @dresses = Dress.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @dresses }
    end
  end

  # GET /dresses/1
  # GET /dresses/1.xml
  def show
    @dress = Dress.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @dress }
    end
  end

  # GET /dresses/new
  # GET /dresses/new.xml
  def new
    @dress = Dress.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @dress }
    end
  end

  # GET /dresses/1/edit
  def edit
    @dress = Dress.find(params[:id])
  end

  # POST /dresses
  # POST /dresses.xml
  def create
    params[:dress][:orderid] = session[:order].id
    @dress = Dress.new(params[:dress])

    respond_to do |format|
      if @dress.save
        format.html { redirect_to(@dress, :notice => 'Dress was successfully created.') }
        format.xml  { render :xml => @dress, :status => :created, :location => @dress }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @dress.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /dresses/1
  # PUT /dresses/1.xml
  def update
    @dress = Dress.find(params[:id])

    respond_to do |format|
      if @dress.update_attributes(params[:dress])
        format.html { redirect_to(@dress, :notice => 'Dress was successfully updated.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @dress.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /dresses/1
  # DELETE /dresses/1.xml
  def destroy
    @dress = Dress.find(params[:id])
    @dress.destroy

    respond_to do |format|
      format.html { redirect_to(dresses_url) }
      format.xml  { head :ok }
    end
  end
end
